package com.mxgraph.examples.swing;

import java.awt.Color;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.util.ArrayList;

import javax.swing.JFrame;
import javax.swing.JMenuBar;
import javax.swing.UIManager;

import com.mxgraph.examples.swing.editor.EditorMenuBar;
import com.mxgraph.swing.util.mxSwingConstants;
import com.mxgraph.util.mxConstants;

class Gui implements Runnable {

    static JMenuBar GraphMenuBar;
    GraphEditor editor;

    public Gui(GraphEditor editor) {
       System.out.println("editor");
        this.editor = editor;
    }

    public void run() {
        {

//ArrayList al = new ArrayList();

            //GraphEditor ob=new GraphEditor(h); 
            //System.out.println("main");



            mxSwingConstants.SHADOW_COLOR = Color.LIGHT_GRAY;
            mxConstants.W3C_SHADOWCOLOR = "#D3D3D3";
            //GraphEditor editor = new GraphEditor();
            GraphMenuBar = new EditorMenuBar(editor);
            //GraphMenuBar.getcom

            final JFrame guiFrame = editor.createFrame((GraphMenuBar));
            //mxGraph graphForThread = editor.graphComponent.getGraph();
            //graphForThread.get
            guiFrame.setDefaultCloseOperation(guiFrame.DO_NOTHING_ON_CLOSE);
            // editor.createFrame(new EditorMenuBar(editor)).setVisible(true);
            guiFrame.addWindowListener(new WindowAdapter() {
                public void windowClosing(WindowEvent e) {


                    //int confirmed = JOptionPane.showConfirmDialog(null,
                    //	"Are you want to save changes?",
                    //	"Save Changes Message Box", JOptionPane.YES_NO_OPTION);

                    //if (confirmed == JOptionPane.NO_OPTION) {
                    //	System.exit(0);
                    // xyz.setVisible(false);
                    // editor.exit(editor);
                    // dispose();
                    //} else {
                    GraphEditor editor = new GraphEditor();
                    EditorMenuBar GraphMenuBar1 = new EditorMenuBar(editor);
                    GraphMenuBar1.exitOption.doClick();
                    System.exit(0);
                    //GraphMenuBar.po
                    //BasicGraphEditor editor =new BasicGraphEditor();
                    //EditorMenuBar trySave = new EditorMenuBar();
                    // public void actionPerformed(ActionEvent e){
                    // BasicGraphEditor editor = getEditor(e);

                    // SaveAction exitSave = new SaveAction(true);
                    //SaveAction save = new SaveAction(true);
                    // save.setEnabled(true);
                    //ActionEvent e1;
                    //WindowAdapter source = this;
                    //e1 = new ActionEvent(source, ActionEvent.ACTION_PERFORMED,
                    //	"null");
                    //save.actionPerformed(e1);
                    // save.(e);
                    // System.exit(0);
                }
                // }
                //}
            });
            JFrame nmsGUI = guiFrame;
            nmsGUI.setVisible(true);




        }

        //@Override

        // TODO Auto-generated method stub

    }
}